# -*- coding: utf-8 -*-
import scrapy
from RoomPriceChongqing.items import RoompricechongqingItem

class RoompriceSpider(scrapy.Spider):
    name = 'RoomPrice'
    # allowed_domains = ['https://cq.fang.anjuke.com/']
    start_urls = ['https://cq.fang.anjuke.com/']

    def parse(self, response):
        room_lists = response.xpath("//div[@class='key-list imglazyload']/div")
        for room in room_lists:
            item = RoompricechongqingItem()
            item['name'] = room.xpath(".//span[@class='items-name']/text()").extract_first()
            item['price'] =room.xpath(".//a[@class='favor-pos']//span/text()").extract_first() 
            yield item
        
        
